package com.cn.kehong.service;

import com.cn.kehong.api.IProductSaojieGuanService;
import com.cn.kehong.dao.ProductSaojieGuanMapper;
import com.cn.kehong.domain.ProductSaojieGuan;
import com.cn.kehong.domain.ProductSaojieGuanExample;
import com.cn.kehong.utils.CollectionsUtil;
import com.cn.kehong.utils.CommonUtil;
import com.cn.kehong.utils.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ProductSaojieGuanServiceImpl implements IProductSaojieGuanService {

    @Autowired
    private ProductSaojieGuanMapper productSaojieGuanMapper;

    @Override
    public List<ProductSaojieGuan> getProductSaojieGuanList(String factoryName) throws Exception {
        ProductSaojieGuanExample example = new ProductSaojieGuanExample();
        example.createCriteria().andStatusEqualTo(Constants.NORMAL_STATUS).andFactoryNameEqualTo(factoryName);
        return productSaojieGuanMapper.selectByExample(example);
    }

    @Override
    public String updateBatchProductSaojieGuans(List<ProductSaojieGuan> productSaojieGuans) throws Exception {
        if(CollectionsUtil.isEmpty(productSaojieGuans)){
            return "数组为空";
        }
        int count = productSaojieGuanMapper.updateBatchProductSaojieGuan(productSaojieGuans);
        return CommonUtil.outStr(count);
    }
}
